package com.finupgroup.postloan.generator.config;

import com.finupgroup.postloan.generator.PropUtils;

/**
 * 全局配置
 *
 * @author YueQingwei
 * @since 2018-04-10
 */
public class GlobalConfig {

    /**
     * 生成文件的输出目录
     */
    private String outputDir;

    /**
     * 开发人员
     */
    private String author;

    /**
     * 开启 BaseResultMap
     */
    private boolean baseResultMap = false;

    /**
     * 开启 baseColumnList
     */
    private boolean baseColumnList = false;

    public GlobalConfig() {
        this.outputDir = defaultOutputDir();
        this.author = PropUtils.get("class.author");
        this.baseResultMap = PropUtils.getBoolean("mapper.resultMap");
        this.baseColumnList = PropUtils.getBoolean("mapper.columnList");
    }

    private String defaultOutputDir() {
        String path = this.getClass().getResource("/").getPath();
        int end = path.indexOf("platform-code-generator") + "platform-code-generator".length();
        return path.substring(0, end) + "/target/generated";
    }

    public String getOutputDir() {
        return outputDir;
    }

    public String getAuthor() {
        return author;
    }

    public boolean isBaseResultMap() {
        return baseResultMap;
    }

    public boolean isBaseColumnList() {
        return baseColumnList;
    }
}
